{% extends 'system_template/public/base_main.html' %}
{% block cite %}新建邮件{% endblock %}
{% block head %}
    <script charset="utf-8" src="{{ url_for('static',filename='lib/kindeditor/kindeditor-all.js') }}"></script>
    <script charset="utf-8" src="{{ url_for('static',filename='lib/kindeditor/lang/zh-CN.js') }}"></script>
    <script src="{{ url_for('static',filename='js/cxcolor.min.js') }}"></script>
    <script>
        KindEditor.ready(function (K) {
            window.editor0 = K.create('#email_content', {
                uploadJson: '{{ url_for('sys_bp.upload') }}',
                allowFileManager: false,
                wellFormatMode: true,
                resizeType: 1,
                formatUploadUrl: false
            });
        });
    </script>
{% endblock %}
{% block content %}
    <form class="layui-form">
        {% for foo in form %}
            {% if foo.type!='BooleanField' %}
                <div class="layui-form-item">
                    <label class="layui-form-label">{{ foo.label }}</label>
                    <div class="layui-input-block">
                        {{ foo }}
                        <div class="layui-form-mid">
                            {% if foo.name=='email_title' %}
                                例如: TL-CMS开发者[<span style="color: red">* 必填</span>]
                            {% elif foo.name=='email_addressee' %}
                                例如: 1368419640@qq.com[<span style="color: red">* 必填</span>]
                            {% endif %}
                        </div>
                    </div>
                </div>
            {% endif %}
        {% endfor %}
        <div class="layui-form-item">
            <div class="layui-input-block">
                <a class="layui-btn" id="submit">确认发送</a>
                <button type="reset" class="layui-btn layui-btn-primary">取消发送</button>
            </div>
        </div>
    </form>
{% endblock %}
{% block footer %}
    <script>
        $(function () {
            $('#submit').click(function () {
                editor0.sync();
                layer.msg('邮件发送中...', {
                    icon: 16
                    , shade: 0.6
                });
                submit_post();
            });
        })
    </script>
{% endblock %}